﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Deeper.Common;
namespace Deeper.DataAccess
{
    [Serializable]
    public class GroupByClip : IClip
    {
        public static readonly GroupByClip None = new GroupByClip((string)null);
        private string groupBy;

        /// <summary>
        /// 自定义一个GroupBy条件
        /// </summary>
        /// <param name="groupBy"></param>
        public GroupByClip(string groupBy)
        {
            this.groupBy = groupBy;
        }

        public static GroupByClip operator &(GroupByClip leftGroup, GroupByClip rightGroup)
        {
            GroupByClip clip = None.BothClip(leftGroup, rightGroup) as GroupByClip;
            if (clip.IsNotNull()) return clip;
            return new GroupByClip(leftGroup.ToString() + "," + rightGroup.ToString());
        }

        public static bool operator true(GroupByClip right)
        {
            return false;
        }

        public static bool operator false(GroupByClip right)
        {
            return false;
        }

        public override string ToString()
        {
            return groupBy;
        }
    }
}
